package com.farm.shop.dao;

import com.farm.device.pojo.Device;
import com.farm.shop.pojo.CustDevice;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

@Repository
public interface CustDeviceMapper extends Mapper<CustDevice> {

    @Update("UPDATE t_cust_device SET `status` = #{status} WHERE `id` = #{id}")
    void  update(Integer id);

    @Insert("INSERT into t_cust_device (cid,did,code,status,install,position) VALUES(#{cid},#{did},#{code},#{status},#{install},#{position}) ")
    void addShop(Map map);

    @Select("SELECT cd.* from t_cust_farmland_device cfd, t_cust_device cd where cfd.cdid=cd.did and cfd.farmland_id=#{farmlandId}")
    List<CustDevice> findCustDevicesByfarmlandId(Integer farmlandId);

    @Select("select name,type,brand,model,scenarios from t_device where id=#{did}")
    List<Device>findById(Integer did);
}
